package com.service;

import com.dao.EmpDao;
import com.pojo.Emp;

import java.util.List;

public class EmpService {
    EmpDao dao = new EmpDao();
    public int insertEmp(Emp emp) {
        int result = 0;
        Emp emp2 = dao.searchByEmpno(emp.getEmpno());
        if (emp2 == null){
            result =  dao.insertEmp(emp);

        }
        return result;
    }

    public List<Emp> searchEmp() {
        return dao.searchEmpno();
    }

    public int delete(int id ) {
        int result = 0;
        Emp emp2 = dao.searchByEmpno(id);
        if (emp2 != null){
            result = dao.delete(id);

        }
        return result;
    }

    public int updateEmp(Emp emp) {

        return dao.updateEmp(emp);
    }
}
